import { ActionReducer, Action } from "@ngrx/store";

export const INC = "INC";
export const DEC = "DEC";
export const RESET = "RESET";

export const counterReducer: ActionReducer<number> = (state: number = 0, action: Action) => {
  switch (action.type) {
    case INC:
      return state + 1;
    case DEC:
      return state - 1;
    case RESET:
      return 0;
    default:
      return state;
  }
};